<?php

/**
 * ShopModel 模型
 * Class ShopModel
 */
class ShopModel extends BaseModel
{

    public $tableName = "shop";
    public $errMsg = '';

    static private $_singleton;

    public function __construct()
    {
        parent::__construct($this->tableName);
    }

    static public function getSingleton()
    {
        if (!self::$_singleton) {
            self::$_singleton = new static();
        }

        return self::$_singleton;
    }

    static public $shopTagsArr = [
        1   => ['icon'=>'fa fa-user-circle-o fa-lg', 'text'=> '到店自提'],
        2   => ['icon'=>'fa fa-truck fa-lg', 'text'=> '物流发货'],
        3   => ['icon'=>'fa fa-wifi fa-lg', 'text'=> '免费wifi'],
        4   => ['icon'=>'fa fa-product-hunt fa-lg   ', 'text'=> '停车位'],
    ];

    public function add($data)
    {
        try {
            $selfModel = static::getSingleton();
            return $selfModel->insert([
                'user_id'           => $data['user_id'],
                'shop_type'         => $data['shop_type'],
                'shop_name'         => $data['shop_name'],
                'shop_description'  => $data['shop_description'],
                'address'           => $data['address'],
                'mobile'            => $data['mobile'],
                'express_money'     => 0,
                'tags'              => isset($data['tags'])? $data['tags']: '2',
                'logo'              => '',
                'gallery_img'       => '',
                'shop_status'       => 1,
                'create_time'       => time()
            ]);
        } catch (Exception $e) {
            $this->errMsg = $e->getMessage();
            return false;
        }
    }


}